public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        int[] nums = new int[]{0,0,1,1,1,2,2,3,3,4};
        int ret = main.removeDuplicates(nums);
        for (int i = 0; i < ret; i++) {
            System.out.print(nums[i] + " ");
        }

    }

    public  int removeDuplicates(int[] nums) {
        int i = 0;
        int j = 1;
        int ret = 0;
        while (j < nums.length) {
            if (nums[i] == nums[j]) {
                j++;
            }
            else{
                i++;
                nums[i] = nums[j];
                j++;
            }
        }
        return i+1;
    }
}
